home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 May / may_2001.iso / intercd / root / Multimedia / ^DivX_Article / virtualdub / VirtualDub-source-1_4d / resample.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-20  |  2.5 KB  |  85 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    Copyright (C) 1998-2001 Avery Lee
  3. //
  4. //    This program is free software; you can redistribute it and/or modify
  5. //    it under the terms of the GNU General Public License as published by
  6. //    the Free Software Foundation; either version 2 of the License, or
  7. //    (at your option) any later version.
  8. //
  9. //    This program is distributed in the hope that it will be useful,
  10. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. //    GNU General Public License for more details.
  13. //
  14. //    You should have received a copy of the GNU General Public License
  15. //    along with this program; if not, write to the Free Software
  16. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18. #ifndef f_RESAMPLE_H
  19. #define f_RESAMPLE_H
  20.  
  21. #include "VBitmap.h"
  22.  
  23. void MakeCubic4Table(int *table, double A, bool mmx_table) throw();
  24. const int *GetStandardCubic4Table() throw();
  25.  
  26. class ResampleInfo {
  27. public:
  28.     union {
  29.         __int64 v;
  30.         struct {
  31.             unsigned long lo;
  32.             long hi;
  33.         };
  34.     } dudx_int, u0_int;
  35.  
  36.     long x1_int, dx_int;
  37.  
  38.     struct ResampleBounds {
  39.         long precopy, preclip, postclip, postcopy, unclipped, allclip;
  40.         long preclip2, postclip2;    // cubic4 only
  41.     } clip;
  42.  
  43.     bool init(double x, double dx, double u, double du, unsigned long xlimit, unsigned long ulimit, int kw, bool bMapCorners, bool bClip4);
  44.  
  45. protected:
  46.     void computeBounds(__int64 u, __int64 dudx, unsigned int dx, unsigned int kernel, unsigned long limit);
  47.     void computeBounds4(__int64 u, __int64 dudx, unsigned int dx, unsigned long limit);
  48. };
  49.  
  50. class Resampler {
  51. public:
  52.     enum eFilter{
  53.         kPoint            = 0,
  54.         kLinearInterp    = 1,
  55.         kCubicInterp    = 2,
  56.         kLinearDecimate    = 3,
  57.         kCubicDecimate    = 4,
  58.     };
  59.  
  60.     Resampler();
  61.     ~Resampler();
  62.     void Init(eFilter horiz_filt, eFilter vert_filt, double dx, double dy, double sx, double sy);
  63.     void Free();
  64.     bool Process(const VBitmap *dst, double _x2, double _y2, const VBitmap *src, double _x1, double _y1, bool bMapCorners) throw();
  65.  
  66. protected:
  67.     ResampleInfo horiz, vert;
  68.     int *xtable, *ytable;
  69.     int xfiltwidth, yfiltwidth;
  70.     double dstw, dsth, srcw, srch;
  71.     double ubias, vbias;
  72.  
  73.     int rowpitch;
  74.     Pixel32 *rowmem, **rows;
  75.     int rowcount;
  76.  
  77.     eFilter    nHorizFilt, nVertFilt;
  78.     
  79.     void _DoRow(Pixel32 *dstp, const Pixel32 *srcp, long srcw);
  80.     static int *_CreateLinearDecimateTable(double dx, double sx, int& filtwidth);
  81.     static int *_CreateCubicDecimateTable(double dx, double sx, int& filtwidth);
  82. };
  83.  
  84. #endif
  85.